golang/xenlight: implement keyed union C to Go marshaling
authorNick Rosbrook <rosbrookn@ainfosec.com>
Mon, 16 Dec 2019 18:08:10 +0000 (18:08 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Mon, 16 Dec 2019 18:08:10 +0000 (18:08 +0000)
commit21cb0bdcf4c12b8edd34f3d086edd76f2e974c32
treef0e9f38eae88ac613fb9b36e65cd138fcfcc724d
parentcc8e54a1a245d8ad35902997a28603018d90444e
golang/xenlight: implement keyed union C to Go marshaling

Switch over union key to determine how to populate 'union' in Go struct.

Since the unions of C types cannot be directly accessed in cgo, use a
typeof trick to typedef a struct in the cgo preamble that is analagous
to each inner struct of a keyed union. For example, to define a struct
for the hvm inner struct of libxl_domain_build_info, do:

  typedef typeof(((struct libxl_domain_build_info *)NULL)->u.hvm) libxl_domain_build_info_type_union_hvm;

Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
tools/golang/xenlight/Makefile
tools/golang/xenlight/gengotypes.py
tools/golang/xenlight/helpers.gen.go